import Vue from 'vue'
import App from './App.vue'

Vue.config.productionTip = false
// 引入 route 路由库
import VueRouter from 'vue-router'
// 引用一级组件
import Ho from './views/Home.vue'
import My from './views/My.vue'
import Ro from './views/Radio.vue'
import Lis from './views/List.vue'
// 引用二级组件
import Hot from './views/Second/Hotsong.vue'
import New from './views/Second/Newsong.vue'
import Sec from './views/Second/Surge.vue'
// 引用404组件
import NotFound from '@/views/NotFound'
//2.添加到Vue.use()身上--注册全局RouterLink和RouterVirw组件
Vue.use(VueRouter)
// 3.创建路由规则数组
const routes = [
  {
    path: '/',
    redirect: '/ho'
  },
  {
    path: '/ho',
    component: Ho
  },
  {
    path: '/my',
    component: My
  },
  {
    path: '/ro',
    component: Ro
  },
  {
    path: '/lis',
    component: Lis,
    children: [
      {
        path: '/hot',
        component: Hot
      },
      {
        path: '/new',
        component: New
      },
      {
        path: '/sec',
        component: Sec
      }
    ]
  },
  {
    path: '*',
    component: NotFound
  }
]
// 4.用规则生成路由对象
let router = new VueRouter({
  routes
})
new Vue({
  render: (h) => h(App),
  router
}).$mount('#app')
